@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		initMenuBtn("btns", "${code}");
	});
	
	function initGrid(){
		var grid_url = ctx + "/${code}/list";
		var _colnames = [
		    "单位名称",
			"办公地点",
			"办公电话",
			"审核状态"
		];
		var _colmodel = [{name:"ID", index:"ID", width:100},
						{name:"address", index:"address", width:100},
						{name:"tel", index:"tel", width:100},
						{name:"status", index:"status", width:100,
                            formatter:function (v,r,i) {
                                if ("0" == v){
                                    return '<a href="#" class="btn btn-btn btn-grey btn-xs" onclick="ckStatus('+"'"+v+"'"+')">'+"待审核"+'</a>';
                                }else{
                                    return '<a href="#" class="btn btn-btn btn-success btn-xs" onclick="ckStatus('+"'"+v+"'"+')">'+"已审核"+'</a>';
                                }
                            }
                        }];
		
		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "id", order : "desc"}
		});
	}
	//检核审核状态
    function ckStatus(status) {

	    var url = '${basePath}/${code}/update';

        if ("1" == status){
            layer.msg("已经审核！");
            return;
        }else {
            layer.confirm("确认进行审核操作吗？",function () {
                var ajax = new $ax(url, function(data){
                    if (data.code == 2901){
                        return false;
                    }
                    if (data.code === 0) {
                        clearLoading(appindex);
                        layer.msg(data.message, {shift: 1});
                        setTimeout(function(){
                            closeTab(true);
                        },500);
                        return false;
                    } else {
                        clearLoading(appindex);
                        if(data.code===999){
                            layer.alert(data.message, {icon: 2,title:"发生错误"});
                        }
                        else{
                            layer.msg(data.message, {shift: 6,time:2000});
                        }
                        return false;
                    }
                });
                // ajax.data = $form.serialize();
                ajax.start();
            });
        }
    }
</script>


	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置 查询 -->
			@ var _col=[
@		{name:"", index:"ID", type:"text"},
			@		{name:"姓名首字母缩写", index:"xmsx", type:"text"},
			@		{name:"审核状态", index:"status", type:"text"}							
			@];
			@ include("/common/_function/_search.html",{"col":_col}){}
			<!-- 按钮 -->
			<div class="welljq well-sm" id="btns"></div>
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}
	
@}	